package com.hellobike.haxing.modules.order.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import com.hellobike.haxing.modules.order.entity.OrderCoupon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: 订单优惠券
 * @Author: haxing-boot
 * @Date:   2020-02-08
 * @Version: V1.0
 */
public interface OrderCouponMapper extends BaseMapper<OrderCoupon> {
    /**
     * 查询订单使用优惠券
     * @param orderId
     * @return
     */
    @Select("select o.*,c.name as \"couponName\",c.id as \"couponId\",c.face_value as \"faceValue\",d.title,d.coupon_amount as \"couponAmount\" from t_order_coupon o,t_user_coupon u,t_coupon c,t_order_detail d where o.user_coupon_id=u.id and u.coupon_id=c.id and o.order_id=d.order_id and o.order_id=#{orderId}")
    List<OrderCoupon> queryList(Long orderId);

    /**
     * 查询订单使用优惠券
     * @param orderId
     * @return
     */
    @Select("select * from t_order_coupon  where order_id=#{orderId}")
    OrderCoupon getOrderCounponOrderId(Long orderId);
}
